-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jansen #7
base: master
Are you sure you want to change the base?
Jansen #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, except for the space complexity you hit the heap class well.
You don't have heapsort here. So... that's missing.
lib/min_heap.rb
Outdated
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(log n), where n is the number of levels in the heap | ||
# Space Complexity: O(1), because there are no extra variables that change with input size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have a recursive heap_up
method, you have to consider the space complexity of that method. So... this is actually O(log n).
The same applies for all your recursive methods.
Heaps Practice
Congratulations! You're submitting your assignment!
Comprehension Questions
n
stands for the number of levels within the tree.heap_up
&heap_down
methods useful? Why?